//
//  KYLoginBgView.m
//  KYKJPackDemo
//
//  Created by Jordan zhou on 2017/9/28.
//  Copyright © 2017年 ???. All rights reserved.
//

#import "KYLoginBgView.h"

@implementation KYLoginBgView

- (instancetype)initWithFrame:(CGRect)frame
{
    if (self = [super initWithFrame:frame]) {
        [self setUpSubViews];
    }
    
    return self;
}

- (instancetype)initWithCoder:(NSCoder *)decoder
{
    if (self = [super initWithCoder:decoder]) {
        [self setUpSubViews];
    }
    
    return self;
}

/**
 *  初始化所有子控件并进行一次性设置
 */
- (void)setUpSubViews
{
    self.backgroundColor = [UIColor blackColor];
    self.alpha = 0.7;
}

/**
 *  拿到真实尺寸进行布局
 */
- (void)layoutSubviews
{
    [super layoutSubviews];
    
    self.frame = CGRectMake(0, 0, self.frame.size.width, self.frame.size.height);
}

/**
 *  显示
 */
- (void)show
{
    UIWindow *appWindow = [[[UIApplication sharedApplication] delegate] window];
    [appWindow addSubview:self];
}

/**
 *  隐藏
 */
- (void)hide
{
    [UIView animateWithDuration:0.15 animations:^{
        self.alpha = 0.0f;
    } completion:^(BOOL finished) {
        [self removeFromSuperview];
    }];
}


@end
